<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
   <%@ include file="/common/CimsCommon.jsp" %>
   <link rel="stylesheet" href="<%=basePath%>/css/cims/cmmBase.css">
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
  
<body style="background-color:#FFFFFF">
<div id="formPageSwap">
  <br/>
<form id="addNewsFormData" name="addNewsFormData" isCheck="true" action="com.jy.modules.common.tcmmquota.controller.TCMmQuotaController">
	<input type=hidden id="dealCode" name="dealCode" value="${dealCode}"/>
	<input type=hidden id="settleFlag" name="settleFlag" value="after"/>
	<div class="expandSwap">
		<div class="ui-widget-header ui-corner-all">
			<span class="text">合约信息</span>
			<!-- <span id="importContract" class="aColor" style="float:right;margin-bottom:10px;text-decoration:underline;cursor:pointer;" onclick=""><b>导入合约</b></span> -->
		</div>
		<div class="expandContent">
			<!--<input type="button" id="importContract" value="导入合约" style="margin-bottom:10px;" onclick=""/> -->
			<%@include file="contractContent.jsp" %>
		</div>
		<!-- <div class="cims_inline_button">
			<ul>
				<li><span class="aColor" style="text-decoration:underline;cursor:pointer;" onclick="download()"><b>导出</b></span></li>
				<li><span class="aColor" style="text-decoration:underline;cursor:pointer;" onclick=""><b>试算</b></span></li>
			</ul>
		</div> -->
		
		<div class="ui-widget-header ui-corner-all">
			<span class="text">债权操作</span>
		</div>
		<div class="expandContent">
			<table id="updateNewsTableId" class="formTableSwap" border="0" align="center" cellpadding="0" cellspacing="1" >
				<tr>
					<th>债权包：</th>
					<td>
						<div class="ui-widget">
							<input type="text" class="text cims_noborder" id="selectPackageName" name="selectPackageName"  value="${dealDto.creditPackageName}" readonly/>
	                        <input type="hidden" class="text cims_noborder" id="selectPackage" name="selectPackage"  value="${dealDto.creditPackageName}" />
						</div>
					</td>
					<th><span id="abnormalSettleTitle">异常结算类型：</span></th>
					<td>
						<syscode:dictionary name="planStatus" extendProperty="notNull=false" defaultValue="${costPlanPlanDto.creditStatus}" codeType="abnormalSettle"
							className="text" type="text"/>
						<input type="hidden" class="text cims_noborder" id="abnormalSettle" name="abnormalSettle" value="${costPlanPlanDto.creditStatus}" />
					</td>
					<th>结算日期：</th><!-- //cims_noborder 无框样式-->
					<td>
						<input type="text" class="text" id="idSettleDate" name="settle" value="${settleDate}" notNull="false" readonly/>
					</td>
				</tr>
			</table>
		</div>
		
		<div id="tableToolbar" class="tableToolbar" style="display:none;">
		  	<a href="javascript:void(0)" onclick="creditSettleLoan()" index="0">导出</a>
	  	</div>
		
		<div id="list">
			
		</div>
		<div class="ui-widget-header ui-corner-all">
			<span class="text">结算信息</span>
		</div>
		<div class="expandContent">
			<table class="formTableSwap" border="0" align="center"
						cellpadding="0" cellspacing="1">
						<tr>
							<th>结算金额 ：</th>
							<td><input type="hidden" class="text cims_noborder"
								id="viewMonthSettle" name="viewMonthSettle"
								value="viewMonthSettle"> <input type="text"
								class="text cims_noborder" id="" name="" value="${dealDto.sumCreditorValue}" readonly /></td>
							<th>需匹配金额：</th>
							<td><input type="text" class="text cims_noborder" id=""
								name="" value="${dealDto.planSellSum}" readonly /></td>
							<th>返还金额：</th>
							<td><input type="text" class="text cims_noborder" id=""
								name="" value="${dealDto.deliverSum}" readonly /></td>
						</tr>
						<tr>
							<th>债权数目：</th>
							<td><input type="text" class="text cims_noborder"
								id="dtostartDate" name="" maxLength="4"
								value="${creditRightDto.detialNumber}"  readonly />
							</td>
							<th>实际匹配金额 ：</th>
							<td><input type="text" class="text cims_noborder"
								id="dtoinvalidDate" name="" value="${dealDto.practicalSellSum}"
								 readonly /></td>
							<th></th>
							<td></td>
						</tr>
					</table>
		</div>
		<div class="expandToolbar">
			<span class="submitBtn" onclick="parent.tabs.close();">关闭</span>
		</div>
	</div>
<!-- 保存 关闭 按钮 在 查询页面进行控制 -->  
</form>

</div>
</body>

<script type="text/javascript">
   var doAddFrom;
   var doContract;
   function exportCreditView(){
	   var url=contextRootPath+"/export/exportSettle?contractCode="+$("#dtocontractCode").val()+"&packageNum="
		+$("#selectPackage").val()+"&templateType="+cimsConstant.DEAL_TYPE_MONTH_BACK
		+"&dealCode="+$("#dealCode").val()+"&cooperorgCode="+$("#dtocooperorgCode").val() +"&dealType="+cimsConstant.DEAL_TYPE_CREDIT_ABNORMAL_SETTLE_REC
		+"&settleFlag="+$("#settleFlag").val()  + "&settleDate=" + $("#idSettleDate").val();
		Cmm.download($("#dtocontractCode").val(),cimsConstant.DEAL_TYPE_MONTH_BACK,url);
   }
   $(document).ready(function(){
   		checkedInit();//平台校验不兼容IE
//    		Cmm.util.checkDdateInit("dtostartDate","dtoinvalidDate");
   		var importBtn=$("#importContract"),
   		    select=$("#selectPackage"),
   		    table;
   		select.on("change",function(){
   			var value=$(this).val();
   			value=value?value:"000";
   			table.url=table.url.split("=")[0]+"="+value+"&contractCode="+dtocontractCode.value;
   			table.query();
   		});
   		doContract=function (contractCode){
   			var table;
   			var url=contextRootPath+"/tCMmQuota/queryOneContractAll?contractCode="+contractCode;
   		    if(table){
   		    	table.url=table.url.split("=")[0]+"=000"+"&dealType="+cimsConstant.DEAL_TYPE_CREDIT_SETTLE;
   		    	table.query();
   		    }
   				jyAjax(url,null,function(msg){
   				//保存成功后，执行查询页面查询方法
   		    	var v_status = msg.status;
   		    	if(v_status.indexOf('ok') >-1){
   		    		var cdto=msg.data.cdto,
   		    			cspDto=msg.data.cspDto,
   		    			cooperorgDTO=msg.data.cooperorgDTO,
   		    			agreementDTO=msg.data.agreementDTO,
   		    			url;
   					table=iframe.iframeObj["table"];
   					url=table.url;
   		    		
   		    		$("input[name=contractCode]").val(cdto.contractCode);
   		    		$("input[name=contractName]").val(cdto.contractName);
   		    		$("input[name=cooperorgCode]").val(cdto.cooperorgCode);
   		    		$("input[name=cooperorgName]").val(cooperorgDTO.cooperorgName);
   		    		$("input[name=agreementCode]").val(cdto.agreementCode);
   		    		$("input[name=agreementName]").val(agreementDTO.agreementName);
   		    		$("select[name=beforeSettleType]").val(cspDto&&cspDto.beforeSettleType);
   		    		$("select[name=overdueType]").val(cspDto&&cspDto.overdueType);
   		    		$("select[name=replaceType]").val(cspDto&&cspDto.replaceType);
   		    		url="${basePath}cooperorgDeal/getPackageList?cooperorgCode="+cdto.cooperorgCode+"&contractCode="+contractCode + "&pagType=" + cimsConstant.CREDIT_RESOURCE;
   		    		jyAjax(url,null,function(msg){
   		    			//保存成功后，执行查询页面查询方法
   		    			var v_status = msg.status;
   		    			if(v_status.indexOf('ok') >-1){
   		    				var array=["<option value=''>--请选择--</option>"],data=msg.data;
   		    				data=data?data:[];
   		    				$.each(data,function(i,n){
   		    					array.push("<option>"+n.creditPackageName+"</option>");
   		    				});
   		    				select.empty();
   		    				select.append(array.join(""));
   		    			}
   		    		});
   		    	}
   			});
   		};
   		!$("#dealCode").val()&&importBtn.trigger("click");
   		
		doAddFrom=function() {
			if (!CheckUtil.formCheck("addNewsFormData")) {
				return;
			}
			if(!select.val()){
				alert("请选择债权包");
				return;
			}
			// 序列化 新增页面的form表单数据
			var params = $("#addNewsFormData").serialize();
			var url = contextRootPath + '/settle/saveMonthSettle';
			// 通过ajax保存
			jyAjax(url, params, function(msg) {
				// 新增成功后，
				// alert(msg.msg);
				var v_status = msg.status;
				if (v_status.indexOf('ok') > -1) {
					// 新增成功后 刷新页面 或 只查询 id为msg.data['id'] 的 数据
					try{
						parent.tabs.getTabWinByTitle("异常贷款交易").queryData();
					}catch(e){
					
					}finally{
						parent.tabs.close();
					}
				}
			});
		};
	});
</script>
 <%@include file="queryTCMmQuotaCreditDetail.jsp" %>
</html>
